<?php

/*
 *
 */

class Model_Mediate_SmsRecord extends Model_BaseModel
{
    use Lib_BaseTraits;
    /**
     * 缓存前缀
     *
     * @var unknown
     */
    private static $tag = 'Model_Mediate_SmsRecord';
    /**
     * Undocumented variable.
     *
     * @var string
     */
    private $table = 'sms_record';

    public function __construct()
    {
        // 选择连接的数据库
        parent::_init('mediation');
    }
    //根据手机号和taskid获取短信记录
    public  function getRecordByMobileTaskid($mobile,$unique_code,$pass=''){

        $sql = "select * from `sms_record` where mobile='{$mobile}' and uniqueCode='{$unique_code}' and sendStatus = 2";
        if($pass){
            $sql .= " and pass='{$pass}'";
        }
        return $this->dao->conn()->setTag(self::$tag)->preparedSql($sql, [])->fetchOne();
    }
    public function getRecordByMobile($mobile){
        $sql = "select * from `sms_record` where mobile=:mobile order by id desc limit 1";
        $data = [
            ':mobile'=>$mobile
        ];
        return $this->dao->conn()->noCache()->preparedSql($sql, $data)->fetchOne();
    }
}
